/**
 * Copyright (C) 2022
 * All rights reserved, Designed By tennisport.cn
 * 注意：
 * 本软件为tennisport.cn开发研制，项目使用请保留此说明
 */
const util = require('../../../utils/util.js')
const app = getApp()

Page({
  data: {
    page: {
      searchCount: false,
      current: 1,
      size: 10,
      ascs: '',//升序字段
      descs: ''
    },
    parameter: {},
    loadmore: true,
    clubList: [],
    viewType: false,
    price: '',
    sales: '',
    createTime: '',
    title: '',
    cityIndex:0,
    cityName:'',
    citysArray: app.globalData.citysArray,
  },
  onLoad(options) {
    this.collectList()
  },
  collectList() {
    app.api.collectList(Object.assign(
      {},
      this.data.page,
      util.filterForm(this.data.parameter)
    ))
      .then(res => {
        console.log(res)
        let clubList = res.rows
        this.setData({
          clubList: [...this.data.clubList, ...clubList]
        })
        if (clubList.length < this.data.page.size) {
          this.setData({
            loadmore: false
          })
        }
      })
  },
  onReachBottom() {
    if (this.data.loadmore) {
      this.setData({
        ['page.current']: this.data.page.current + 1
      })
      this.collectList()
    }
  },
  relod(){
    this.setData({
      loadmore: true,
      clubList: [],
      ['page.current']: 1
    })
    this.collectList()
  }
})
